<div class="bjui-pageHeader">
    <form id="pagerForm" data-toggle="ajaxsearch" action="${request.getContextPath()}/OutsrcSummary/outsrcSummary" method="post">
        <div class="bjui-searchBar">
            <g:hiddenField name="SYS_QUERY_NAME" value="outsrcSummary" />
            <g:hiddenField name="EXPORT_CONTENT_NAME" value="Excel" />
            <label >受入时间：</label>
            <input type="text" name="startTime" value="${startTime}" data-pattern="yyyy-MM-dd" size="12" data-toggle="datepicker" placeholder="FROM">
            <input type="text" name="endTime" value="${endTime}" data-pattern="yyyy-MM-dd" size="12" data-toggle="datepicker" placeholder="TO">&nbsp;
            <label >委外单号：</label>
            <input type="text" name="outsrcId" value="${outsrcId}" size="17" placeholder="委外单号"/>&nbsp;
            <label >存货编码/图号：</label>
            <input type="text" name="part" value="${part}" size="17" placeholder="存货编码/图号"/>&nbsp;
            <label >状态：</label>
            <g:select name="state" from="${outsrcSummaryState}" data-toggle="selectpicker" data-live-search="true" 
                      optionKey="state" optionValue="state" value="${state}" data-width="130" noSelection="['':'-- All --']" />
            <br /><br />
            <label >加工单位：</label>
            <g:select name="jiagongdanwei" from="${outsrcSummaryDanwei}" data-toggle="selectpicker" data-live-search="true"
                      optionKey="description" optionValue="description" value="${jiagongdanwei}" data-width="130" noSelection="['':'-- All --']" />&nbsp;
            <label >外发人工号：</label>
            <input type="text" name="userId" value="${userId}" size="17" placeholder="外发人工号"/>
            <label >外发人姓名：</label>
            <input type="text" name="userName" value="${userName}" size="17" placeholder="外发人姓名"/>
            <button type="submit" class="btn-default" data-icon="search">查询</button>
            %{--<button type="button" class="btn-blue" onclick="javascript:bjuiExportExl('#pagerForm','${request.getContextPath()}/StageWip/exportExcel')" --}%
                    %{--data-icon="file-excel-o" title="导出Excel">导出</button>--}%
            %{--<a type="button" class="btn btn-blue" href="${request.getContextPath()}/Base/exportExcel"
               data-toggle="doexport" data-confirm-msg="确定要导出吗？" data-icon="file-excel-o" title="导出Excel">导出</a>--}%
            <button type="button" class="btn-blue" onclick="javascript:bjuiExportExl('#pagerForm','${request.getContextPath()}/OutsrcSummary/exportExcel')" data-icon="file-excel-o" title="导出Excel">导出</button>&nbsp;
        </div>
    </form>
</div>

<div class="panel-body">

    <div style="mini-width:400px;height:450px;" id="cellGlassOutputDiv"></div>
</div>

<div class="bjui-pageContent tableContent">
    <g:if test="${outsrcSummary.size() > 0}">
        <table  data-toggle="tablefixed" data-width="100%" data-nowrap="true">
            <thead>
            <tr id="t1">
                <g:each in="${tableHeadList}" status="j" var="headInstance">
                    <g:if test="${headInstance!='RN'}">
                        <th width="150"><g:message code="${headInstance}" default="${headInstance}"/></th>
                    </g:if>
                </g:each>
            </tr>
            </thead>
            <tbody>
            <g:if test="${outsrcSummary.size()>0}">
                <g:each in="${outsrcSummary}" status="i" var="dataInstance">
                    <tr>
                        <g:each in="${tableHeadList}" status="j" var="headInstance">
                            <g:if test="${headInstance=='MAIN_QTY'&&headInstance!='RN'}">
                                <td name="OUTSRCSUM${i}">${dataInstance["${headInstance}"]}</td>
                            </g:if>
                            <g:elseif test="${headInstance=='CURRENT_STEP_TIME'&&headInstance!='RN'}">
                                <td name="OUTSRCTIME${i}">${dataInstance["${headInstance}"]}</td>
                            </g:elseif>
                            <g:elseif test="${headInstance!='RN'}">
                                <td>${dataInstance["${headInstance}"]}</td>
                            </g:elseif>
                        </g:each>
                    </tr>
                </g:each>
                <tr>
                    <td colspan="14">小计</td>
                    <td name="outsrcSumShow">0</td>
                </tr>
                <tr>
                    <td colspan="14">合计</td>
                    <td>${outsrcSummarySumQty.SUM_QTY[0]}</td>
                </tr>
            </g:if>
            <g:else>
                <g:render template="../template/emptyPanel" />
            </g:else>
            </tbody>
        </table>
    </g:if>
</div>
<g:render template="../template/51pagination" />
<script>
    $(function(){
        var outsrcSumQty=0;
        for(var i=0;i<${outsrcSummary.size()};i++){
            var outsrcsumqty='OUTSRCSUM'+i
            var outsrcSumAdd=$("td[name='"+outsrcsumqty+"']").text()==''?0:parseInt($("td[name='"+outsrcsumqty+"']").text())
            outsrcSumQty+=outsrcSumAdd
        }
        $("td[name='outsrcSumShow']").html(outsrcSumQty)

        //
        for(var i=0;i<${outsrcSummary.size()};i++){
            var outsrcStayTime="OUTSRCTIME"+i;
            var outsrcTimeJudge=parseFloat($("td[name='"+outsrcStayTime+"']").text())
            if(outsrcTimeJudge>=1&&outsrcTimeJudge<3){
                $("td[name='"+outsrcStayTime+"']").css("background-color","#FFFF6F")
                $("td[name='"+outsrcStayTime+"']").nextAll().css("background-color","#FFFF6F")
                $("td[name='"+outsrcStayTime+"']").prevAll().css("background-color","#FFFF6F")

            }else if(outsrcTimeJudge>=3&&outsrcTimeJudge<7){
                $("td[name='"+outsrcStayTime+"']").css("background-color","#FF9797")
                $("td[name='"+outsrcStayTime+"']").nextAll().css("background-color","#FF9797")
                $("td[name='"+outsrcStayTime+"']").prevAll().css("background-color","#FF9797")
            }else if(outsrcTimeJudge>=7){
                $("td[name='"+outsrcStayTime+"']").css("background-color","#FF5151")
                $("td[name='"+outsrcStayTime+"']").nextAll().css("background-color","#FF5151")
                $("td[name='"+outsrcStayTime+"']").prevAll().css("background-color","#FF5151")
            }
        }
    })
</script>
